#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;


int M, N, T;
int enemy[200][200];
int minLen[200][200][10];
int xs, ys;
int xe, ye;
int minTime = 0;
int totalTime;
int totalT;
int visited[200][200];

int pos[4][2] = { {-1,0},{0,-1},{1,0 },{0,1} };

void read_data()
{
	memset(enemy, 0, sizeof(enemy));
	cin >> M >> N >> T;
	char p;
	for (int i = 0; i < M; ++i) {
		for (int j = 0; j < N; ++j)
		{
			cin >> p;
			switch (p)
			{
			case '#':
				enemy[i][j] = 1;
				break;
			case '@':
				xs = i;
				ys = j;
				break;
			case '+':
				xe = i;
				ye = j;
				break;
			}
			for (int k = 0; k <= T; ++k)
				minLen[i][j][k] = 1 << 30;
		}
	}
}

bool valid(int x, int y)
{
	return 0 <= x && x < M && 0 <= y && y < N;
}

void DFS(int x, int y)
{
	if (x == xe && y == ye) {
		minTime = min(minTime, totalTime);
		return;
	}
	if (totalT > T || minLen[x][y][totalT]<totalTime || totalTime >= minTime)
		return;
	for (int i = 0; i < 4; ++i)
	{
		int x1 = x + pos[i][0];
		int y1 = y + pos[i][1];
		if (valid(x1, y1) && !visited[x1][y1])
		{
			if (enemy[x1][y1]) {
				if (totalT + 1 > T)
					continue;
				else
					totalT++;
			}
			visited[x1][y1] = 1;
			totalTime++;
			if (minLen[x1][y1][totalT] > totalTime)
				minLen[x1][y1][totalT] = totalTime;
			DFS(x1, y1);
			totalTime--;
			if (enemy[x1][y1])
				totalT--;
			visited[x1][y1] = 0;
		}
	}
}

void solve()
{
	minTime = 1 << 30;
	totalT = 0;
	totalTime = 0;
	memset(visited, 0, sizeof(visited));
	visited[xs][ys] = 1;
	DFS(xs, ys);
	cout << minTime << endl;
}

int main()
{
	freopen("e09-01.txt", "r", stdin);
	read_data();
	solve();
	return 0;
}